let newsModel = require("../models/newsList").newsList;

let newsDAO = function (){};

newsDAO.prototype = {
  //增
  save: function (json, callBack){
    let newNews = new newsModel(json);
    newNews.save(function (err){
      callBack(err);
    });
  },
  //删
  remove: function (json, callBack){
    newsModel.remove(json, function (err){
      callBack(err);
    });
  },
  //改
  update: function (json, condition, callBack){
    newsModel.update(json, condition, function (err){
      callBack(err);
    });
  },
  //查
  findOne: function (json, callBack){
    newsModel.findOne(json, function (err, doc){
      callBack(err, doc);
    });
  },
  // 查询全部列表
  findAll: function ( callBack){
    newsModel.find(function (err, doc){
      callBack(err, doc);
    });
  },
};

exports.newsMethod = new newsDAO();
